<?php

use yii\helpers\Html;
use yii\grid\GridView;

/* @var $this yii\web\View */
/* @var $searchModel common\models\MktFriendSearch */
/* @var $dataProvider yii\data\ActiveDataProvider */

$this->title = '好友';
$this->params['breadcrumbs'][] = $this->title;
$this->params['breadcrumbs'][] = $model->name;
?>
<div class="mkt-friend-index">

    <?php // echo $this->render('_search', ['model' => $searchModel]); ?>

    <p>
        <?php echo Html::a('加好友', ['create', 'user_id' => $model->id], ['class' => 'btn btn-success']) ?>
    </p>

    <?php echo GridView::widget([
        'dataProvider' => $dataProvider,
        //'filterModel' => $searchModel,
        //'filterModel' => false,
        'columns' => [
            //['class' => 'yii\grid\SerialColumn'],

            //'id',
            //'user_id',
            //'friend_id',
            [
                'label' => '好友ID',
                'value'=>function ($model, $key, $index, $column) { 
                    return $model->friend_id; 
                },
            ],
			[
				'label' => '好友头像',
				'format'=>'html',
				'value'=>function ($model, $key, $index, $column) { 
                    if (empty($model->friendUser->headimgurl))
                        return '';
                    $headimgurl = Html::img(\common\wosotech\Util::getWxUserHeadimgurl($model->friendUser->headimgurl, 46), ['style'=>'width:46px;']);
                    return $headimgurl;
				},
			],

            [
                'label' => '好友姓名',
                'value'=>function ($model, $key, $index, $column) { 
                    return $model->friendUser->name . "({$model->friendUser->sex})"; 
                },
            ],

            [
                'label' => '好友微信昵称',
                'value'=>function ($model, $key, $index, $column) { 
                    return $model->friendUser->nickname; 
                },
            ],

            ['class' => 'yii\grid\ActionColumn',
              'template' => '{delete}',  
            ],

        ],
    ]); ?>

</div>
